/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 */

import React, { useState } from 'react';
import { StatusBar, useColorScheme } from 'react-native';
import { Provider } from '@ant-design/react-native';
import { SafeAreaProvider } from 'react-native-safe-area-context';

import LoginScreen from './src/screens/LoginScreen';
import CustomTabNavigator from './src/components/CustomTabNavigator';

function App() {
  const isDarkMode = useColorScheme() === 'dark';
  const [isLoggedIn, setIsLoggedIn] = useState(false);

  const handleLoginSuccess = () => {
    setIsLoggedIn(true);
  };

  const handleLogout = () => {
    setIsLoggedIn(false);
  };

  return (
    <SafeAreaProvider style={{ backgroundColor: '#fff' }}>
      <Provider>
        <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
        {isLoggedIn ? (
          <CustomTabNavigator onLogout={handleLogout} />
        ) : (
          <LoginScreen onLoginSuccess={handleLoginSuccess} />
        )}
      </Provider>
    </SafeAreaProvider>
  );
}

export default App;
